fix: don't cache preloaded redirect results#16486
Open
ondraulehla wants to merge 1 commit into
Open
Conversation
The preload cache stored redirect results from load and replayed them on navigation without re-running load. Since the cache is only cleared once a navigation commits and a redirect never commits one, a preloaded redirect into a mutually-redirecting pair looped until the 20-redirect limit, even when a fresh evaluation would resolve. Discard the cache when the preload resolves to a redirect, matching the existing behavior for errors: both are transient results that must be re-evaluated at navigation time. Fixes sveltejs#16484
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/df6f5f367b3184b900bae88d738c97bbe747eb48Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: df6f5f3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #16484
When a link is preloaded and the target's
loadreturnsredirect(...),the client caches that redirect result and replays it on navigation
without re-running
load. The cache is only cleared once a navigationcommits, and a redirect never commits one. So a preloaded redirect into
a pair of mutually redirecting routes loops until the 20 redirect limit,
even when a fresh evaluation would resolve. The issue has a minimal
repro of an onboarding style gate.
I made
_preload_datadiscard the cache when the result is a redirect.This matches how it already refuses to cache errors, since both are
transient results that have to be re-evaluated at navigation time.
The new test reproduces the gate scenario from the issue. It preloads a
route whose load redirects, then clicks. Without the fix it ends in a
redirect loop, with the fix the navigation resolves. Passes in dev and
build modes.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
lint-allcurrently fails on upstream main itself (pre-existing, unrelated)Changesets
@sveltejs/kitpatch,fix:prefix)Edits